package com.heima.comment.controller.v1;

import com.baomidou.mybatisplus.extension.api.R;
import com.heima.comment.service.ApArticleCommentService;
import com.heima.model.comment.dtos.ArticleSaveDto;
import com.heima.model.comment.dtos.CommentLikeDto;
import com.heima.model.comment.dtos.CommentPageDto;
import com.heima.model.common.dtos.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
@RequestMapping("/api/v1/comment")
public class ArticleCommentController {

    @Autowired
    private ApArticleCommentService apArticleCommentService;

    //保存评论
    @PostMapping("/save")
    public ResponseResult save(@RequestBody ArticleSaveDto dto) {
         return apArticleCommentService.saveComment(dto);

    }

    //查询评论列表
    @PostMapping("/load")
    public ResponseResult<CommentPageDto> load(@RequestBody CommentPageDto pageDto){
       return apArticleCommentService.load(pageDto);

    }

    //评论点赞
    @PostMapping("/like")
    public ResponseResult like(@RequestBody CommentLikeDto dto){
        return apArticleCommentService.like(dto);
    }

}
